<?php
require_once('../../config.php');
Doctrine::loadModels('../../models');

if( $_GET["agent_id"]) // AND $_GET["item_name"] AND $_GET["category_id"] AND $_GET["item_desc"] AND $_GET["item_value"])
{
	$profit_loss_id = strip_tags($_GET["profit_loss_id"]);
    $project_id = strip_tags($_GET["project_id"]);
    $fin_year_id = strip_tags($_GET["fin_year_id"]);
	$rev_exp_id = strip_tags($_GET["rev_exp_id"]);
	$org_fin_centre_id = strip_tags($_GET["org_fin_centre_id"]);
	$m01_budget = strip_tags($_GET["m01_budget"]);
	$m02_budget = strip_tags($_GET["m02_budget"]);
	$m03_budget = strip_tags($_GET["m03_budget"]);
	$m04_budget = strip_tags($_GET["m04_budget"]);
	$m05_budget = strip_tags($_GET["m05_budget"]);
	$m06_budget = strip_tags($_GET["m06_budget"]);
	$m07_budget = strip_tags($_GET["m07_budget"]);
	$m08_budget = strip_tags($_GET["m08_budget"]);
	$m09_budget = strip_tags($_GET["m09_budget"]);
	$m10_budget = strip_tags($_GET["m10_budget"]);
	$m11_budget = strip_tags($_GET["m11_budget"]);
	$m12_budget = strip_tags($_GET["m12_budget"]);
	$m01_actual = strip_tags($_GET["m01_actual"]);
	$m02_actual = strip_tags($_GET["m02_actual"]);
	$m03_actual = strip_tags($_GET["m03_actual"]);		
	$m04_actual = strip_tags($_GET["m04_actual"]);
	$m05_actual = strip_tags($_GET["m05_actual"]);
	$m06_actual = strip_tags($_GET["m06_actual"]);
	$m07_actual = strip_tags($_GET["m07_actual"]);
	$m08_actual = strip_tags($_GET["m08_actual"]);
	$m09_actual = strip_tags($_GET["m09_actual"]);
	$m10_actual = strip_tags($_GET["m10_actual"]);
	$m11_actual = strip_tags($_GET["m11_actual"]);
	$m12_actual = strip_tags($_GET["m12_actual"]);
	
	file_put_contents  ( "params_insert.txt", 
								"profit_loss_id '" .$profit_loss_id. 
								"' project_id '" .$project_id.
								"' fin_year_id '" .$fin_year_id.
								"' rev_exp_id '" .$rev_exp_id.
								"' org_fin_centre_id '" .$org_fin_centre_id.
								"' m01_budget '" .$m01_budget.
								"' m02_budget '" .$m02_budget.
								"' m03_budget '" .$m03_budget.
								"' m04_budget '" .$m04_budget.
								"' m05_budget '" .$m05_budget.
								"' m06_budget '" .$m06_budget.
								"' m07_budget '" .$m07_budget.
								"' m08_budget '" .$m08_budget.
								"' m09_budget '" .$m09_budget.
								"' m10_budget '" .$m10_budget.
								"' m11_budget '" .$m11_budget.
								"' m12_budget '" .$m12_budget.
								"' m01_actual '" .$m01_actual.
								"' m01_actual '" .$m02_actual.
								"' m01_actual '" .$m03_actual.
								"' m01_actual '" .$m04_actual.
								"' m01_actual '" .$m05_actual.
								"' m01_actual '" .$m06_actual.
								"' m01_actual '" .$m07_actual.
								"' m01_actual '" .$m08_actual.
								"' m01_actual '" .$m09_actual.
								"' m01_actual '" .$m10_actual.
								"' m01_actual '" .$m11_actual.
								"' m01_actual '" .$m12_actual."'");
	
	$db_query = sprintf("UPDATE fin_profit_loss 
							SET $project_id='".$project_id."',
								$fin_year_id='".$fin_year_id."',
								$rev_exp_id='".$rev_exp_id."',
								org_fin_centre_id='".$org_fin_centre_id."',
								m01_budget='".$m01_budget."',
								m02_budget='".$m02_budget."',
								m03_budget='".$m03_budget."',
								m04_budget='".$m04_budget."',
								m05_budget='".$m05_budget."',
								m06_budget='".$m06_budget."',
								m07_budget='".$m07_budget."',
								m08_budget='".$m08_budget."',
								m09_budget='".$m09_budget."',
								m10_budget='".$m10_budget."',
								m11_budget='".$m11_budget."',
								m12_budget='".$m12_budget."',
								m01_actual='".$m01_actual."',
								m02_actual='".$m02_actual."',
								m03_actual='".$m03_actual."',
								m04_actual='".$m04_actual."',
								m05_actual='".$m05_actual."',
								m06_actual='".$m06_actual."',
								m07_actual='".$m07_actual."',
								m08_actual='".$m08_actual."',
								m09_actual='".$m09_actual."',
								m10_actual='".$m10_actual."',
								m11_actual='".$m11_actual."',
								m12_actual='".$m12_actual."' 
							WHERE profit_loss_id='".$profit_loss_id."'");
 
 	file_put_contents  ( "update_statement.txt", $db_query);   
 
 	$result = mysql_query($db_query);
    	if (!$result) {
        		die('invalid query');    // . mysql_error());
    		}
}

mysql_free_result( $result )
	
?>